#ifndef SCREENCASTING_TEACHING_SYSTEM___CLIENT___MEDIA___PACKET_QUEUE_H_
#define SCREENCASTING_TEACHING_SYSTEM___CLIENT___MEDIA___PACKET_QUEUE_H_

extern "C" {
	#ifndef INT64_C
	#define INT64_C(c) (c ## LL)
	#define UINT64_C(c) (c ## ULL)
	#endif
	#include <libavformat/avformat.h>
	#include <libavutil/avstring.h>
	#include <libavcodec/avcodec.h>
	#include <libswscale/swscale.h>
	#include <SDL.h>
}

#include "../../common/comm/lock.h"
#include "../../common/comm/mutex.h"
#include "../../common/comm/conditionvariable.h"

/**
 * Thread safe packet queue.
 */
class PacketQueue {
private:
	AVPacketList *firstPkt, *lastPkt;
	int nbPackets_;
	int size_;
	int abortRequest_;

	Mutex mutex_;
	ConditionVariable cond_;

public:
	PacketQueue();
	~PacketQueue();
	void stopWaiting();
	int put(AVPacket *pkt);
	int get(AVPacket *pkt);
	int size() { return size_; }
};

#endif /* SCREENCASTING_TEACHING_SYSTEM___CLIENT___MEDIA___PACKET_QUEUE_H_ */
